******Master teacher survey do file****
******Purpose: To run all the cleaning do files 
******for the teacher survey and save a clean data set
******Last modified: 27th March 2019****

clear all 
cap log close




do "[directory]/02 Teacher_Survey_Cleaning.do"



do "[directory]/03 Teacher_Survey_Correction.do"



do "[directory]/04 Teacher_Survey_Correction.do"

save "[directory]/teacher_endline_preclean.dta", replace


do "[directory]/05 Teacher_Survey_Correction_final.do"

	local piivars first_name_109 family_name_109
	local piinum -99999
	local piistr NONPII VERSION
	generate piiid = _n
	ds `piivars', has(type numeric)
	foreach var in `r(varlist)' {
		replace `var' = `piinum' if !missing(`var')
	}
	ds `piivars', has(type string)
	foreach var in `r(varlist)' {
		replace `var' = "`piistr'" if !inlist(`var', "", "don't know", "refusal")
	}

save "[directory]/teacher_endline_clean_final_NOPIIs.dta", replace

